<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/admin/business.js"></script> 
<div class="right">
	<div id="bread-nav" class="fn-clear">
		<ul>
			<li><a href="admin/home">后台首页</a></li>
			<li><a>商户管理</a></li>
		</ul>
	</div>
	<div id="content" class="text-darkgrey">
		<h2>商户管理</h2>
		<div class="add">
			<a href="admin/business/upload">导入商户列表</a>
			<a href="admin/business/add">新增商户</a>
		</div>
		
		<p class="text-yellow">筛选商户</p>
		<?=form_open("admin/business/businessList/",$form)?>
			<p>分类一：
				<select name="class1" id="class1">
					<option value="0" <?php if($class1==0):?>selected="selected"<?php endif;?>>所有分类</option>
				<?php foreach ($class1List as $row):?>
					<option value="<?=$row['id']?>" <?php if($class1==$row['id']):?>selected="selected"<?php endif;?>><?=$row['name']?></option>
				<?php endforeach;?>
				</select>
				　分类二：
				<select name="class2" id="class2">
					<option value="0" <?php if($class2==0):?>selected="selected"<?php endif;?>>所有分类</option>
					<?php if($class1>0):
						foreach ($class2List as $row):?>
					<option value="<?=$row['id']?>" <?php if($class2==$row['id']):?>selected="selected"<?php endif;?>><?=$row['name']?></option>
					<?php endforeach;endif;?>
				</select>
				　行政区：
				<select name="region" id="region">
					<option value="0" <?php if($region==0):?>selected="selected"<?php endif;?>>所有分类</option>
				<?php foreach ($regionList as $row):?>
					<option value="<?=$row['id']?>" <?php if($region==$row['id']):?>selected="selected"<?php endif;?>><?=$row['name']?></option>
				<?php endforeach;?>
				</select>
				　　商区：
				<select name="area" id="area">
					<option value="0" <?php if($area==0):?>selected="selected"<?php endif;?>>所有分类</option>
					<?php if($region>0):
						foreach ($areaList as $row):?>
					<option value="<?=$row['id']?>" <?php if($area==$row['id']):?>selected="selected"<?php endif;?>><?=$row['name']?></option>
					<?php endforeach;endif;?>
				</select>
			</p>
			<p>
				可回收：
				<select name="recycle" id="recycle">
					<option value="N" <?php if($recycle=='N'):?>selected="selected"<?php endif;?>>全部</option>
					<option value="T" <?php if($recycle=='T'):?>selected="selected"<?php endif;?>>可回收</option>
					<option value="F" <?php if($recycle=='F'):?>selected="selected"<?php endif;?>>不可回收</option>
				</select>
				　　状态：
				<select name="state" id="state">
					<option value="A" <?php if($state=='A'):?>selected="selected"<?php endif;?>>全部</option>
					<option value="N" <?php if($state=='N'):?>selected="selected"<?php endif;?>>正常</option>
					<option value="U" <?php if($state=='U'):?>selected="selected"<?php endif;?>>即将开通</option>
					<option value="P" <?php if($state=='P'):?>selected="selected"<?php endif;?>>暂停使用</option>
					<option value="S" <?php if($state=='S'):?>selected="selected"<?php endif;?>>停用</option>
				</select>
				　　推送：
				<select name="show" id="show">
					<option value="N" <?php if($show=='N'):?>selected="selected"<?php endif;?>>全部</option>
					<option value="T" <?php if($show=='T'):?>selected="selected"<?php endif;?>>推送</option>
					<option value="F" <?php if($show=='F'):?>selected="selected"<?php endif;?>>不推送</option>
				</select>
				　　　总店：
				<select name="groupName" id="groupName">
					<option value="0" <?php if($groupName==0):?>selected="selected"<?php endif;?>>所有商户</option>
					<?php if($groupNameList):
						foreach ($groupNameList as $row):?>
					<option value="<?=$row['groupName']?>" <?php if($groupName==$row['groupName']):?>selected="selected"<?php endif;?>><?=$row['groupName']?></option>
					<?php endforeach;endif;?>
				</select>
				<input id="search" type="text" name="search" class="input"  value="<?=$search?>" />
				　<input type="submit" id="submitCheck" value="筛选" class="submit">
			</p>
		</form>
			
		<?php if ($num > 0) : ?>
		<div class="table-container">
		<table style="width:1240px;">
			<tr>
			<td class="short text-red center">编号</td>
			<td class="middle text-red center">商户名</td>
			<td class="middle text-red center">总店名</td>
			<td class="middle text-red center">地址</td>
			<td class="middle text-red center">电话</td>
			<td class="middle text-red center">一级分类</td>
			<td class="middle text-red center">二级分类</td>
			<td class="middle text-red center">行政区</td>
			<td class="middle text-red center">商区</td>
			<td class="middle text-red center">可回收</td>
			<td class="middle text-red center">推送</td>
			<td class="middle text-red center">状态</td>
			<td class="middle text-red center">描述</td>
			<td class="middle text-red center">时间</td>
			<td class="middle text-red center">管理</td>
			<td class="short text-red center">编辑</td>
			<td class="short text-red center">删除</td>
			</tr>
			<?foreach ($businessList as $row):?>
				<tr>
				<td class="short center"><?=$row['id']?></td>
				<td class="middle"><?=$row['name']?></td>
				<td class="middle"><?=$row['groupName']?></td>
				<td class="middle"><?=$row['address']?></td>
				<td class="middle"><?=$row['phone']?></td>
				<td class="middle center"><?=$row['class1Name']?></td>
				<td class="middle center"><?php if($row['class2']>0) echo $class2List2[$row['class2']-1]['name'];else echo '';?></td>
				<td class="middle center"><?=$row['regionName']?></td>
				<td class="middle center"><?=$row['areaName']?></td>
				<td class="middle center">
				<?php if($row['recycle']=='T'):?>
	         	可回收
	         	<?php elseif ($row['recycle']=='F'):?>
	         	不回收
	         	<?php endif;?>
	         	</td>
				<td class="middle center">
				<?php if($row['show']=='T'):?>
	         	推送
	         	<?php elseif ($row['show']=='F'):?>
	         	不推送
	         	<?php endif;?>
				</td>
				<td class="middle center">
				<?php if($row['state']=='N'):?>
	         	正常
	         	<?php elseif ($row['state']=='U'):?>
	         	即将开通
	         	<?php elseif ($row['state']=='P'):?>
	         	暂停使用
	         	<?php elseif ($row['state']=='S'):?>
	         	停用
	         	<?php endif;?>
	         	</td>
	         	<td class="middle"><?=$row['details']?></td>
				<td class="middle center"><?=date('Y-m-d H:i:s',strtotime($row['updateTime']))?></td>
				<td class="middle center"><?=$row['updatePerson']?></td>
				<td class="short center"><a href="admin/business/edit/<?=$row['id']?>">编辑</a></td>
				<td class="short center"><input type="button" onclick="deal(<?=$row ['id']?>)" value="删除"  class="padding" /></td>
				</tr>
			<?php endforeach;?>
		</table>
		</div>
		<div id="page-nav" class="fn-clear"><?php echo $this->pagination->create_links ();?></div>
		<?php else : ?>
		<p>没有商户！</p>
		<?php endif;?>
	</div>
	<script type="text/javascript">
	function deal(str) {
		if (confirm("确认删除记录"+str+"？")){
			window.location = getRootPath()+'/admin/business/delete/'+str;
		}
	}
	</script>
</div>